Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor FXIOS-10467 - Remove force_cast violations from Sistem services & Logging #23150

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bmihai23
Copy link
Contributor

@bmihai23 bmihai23 commented Nov 15, 2024

📜 Tickets

Jira ticket
Github issue

💡 Description

  • This PR remove force_cast violations from:
    • CrashManager
    • MenuBuilderHelper
  • This PR is part of a series aimed at adding a new SwiftLint rule in the project, as described in Swiftlint: force_cast #22916

📝 Checklist

You have to check all boxes before merging

  • Filled in the above information (tickets numbers and description of your work)
  • Updated the PR name to follow our PR naming guidelines
  • Wrote unit tests and/or ensured the tests suite is passing
  • When working on UI, I checked and implemented accessibility (minimum Dynamic Text and VoiceOver)
  • If needed, I updated documentation / comments for complex code and public methods
  • If needed, added a backport comment (example @Mergifyio backport release/v120)

@bmihai23 bmihai23 requested a review from a team as a code owner November 15, 2024 10:55
Copy link
Collaborator

@FilippoZazzeroni FilippoZazzeroni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉 just some nit things. Great work 🚀

import UIKit
import Shared

class MenuBuilderHelper {
private let logger: Logger

init(logger: Logger = DefaultLogger.shared) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks good, i'd only move the init after the structs, so the init is with the other methods

@@ -255,7 +280,13 @@ class MenuBuilderHelper {

if #available(iOS 15, *) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also remove the #if available now we support from iOS 15

($0 as! UIKeyCommand).wantsPriorityOverSystemBehavior = true
guard let fileMenuKeyCommand = $0 as? UIKeyCommand else {
logger.log("Failed to cast file menu child to UIKeyCommand in MenuBuilderHelper class",
level: .fatal,
Copy link
Collaborator

@FilippoZazzeroni FilippoZazzeroni Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd log those as a .info level since there is no crash there and we don't send them to sentry as well.
Same for the other logs. i'd also use .lifecycle i see there isn't a proper one for menu but i guess lifecycle is more general

self.alterEventForCustomCrash(event: event, crash: crashReport)
} else {
self.logger.log("Encountered an error that is not a CustomCrashReport: \(String(describing: event.error))",
level: .fatal,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here i'd go to .info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants